package com.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.pojo.ServiceItem;
import com.pojo.ServiceMerchant;
import org.apache.ibatis.annotations.One;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;
@Repository
public interface ServiceListDao extends BaseMapper<ServiceItem> {
    @Results({
            @Result(id=true,property = "id",column = "id"),
            @Result(property = "name",column = "name"),
            @Result(property = "introduce",column = "introduce"),
            @Result(property = "supportTime",column = "supportTime"),
            @Result(property = "photo",column = "photo"),
            @Result(property = "price",column = "price"),
            @Result(property = "status",column = "status"),
            @Result(property = "serviceMerchant",column = "mid",javaType = ServiceMerchant.class,
            one = @One(select = "com.dao.ServiceMerchantDao.findByMid"))
    })
    @Select("select * from service_item where type=#{type} and cid=#{cid}")
    List<ServiceItem> findByTypeandCid(String type, Integer cid);
    @Results({
            @Result(id=true,property = "id",column = "id"),
            @Result(property = "name",column = "name"),
            @Result(property = "introduce",column = "introduce"),
            @Result(property = "supportTime",column = "supportTime"),
            @Result(property = "photo",column = "photo"),
            @Result(property = "price",column = "price"),
            @Result(property = "status",column = "status"),
            @Result(property = "serviceMerchant",column = "mid",javaType = ServiceMerchant.class,
                    one = @One(select = "com.dao.ServiceMerchantDao.findByMid"))
    })
    @Select("select * from service_item where cid=#{cid}")
    List<ServiceItem> goodsFindAll(Integer cid);
    @Select("select * from service_item where id=#{iid}")
    List<ServiceItem> findById(Integer iid);
}
